package com.example.tests;

public class PersonData implements Comparable<PersonData> {

	public String secondName;
	public String firstName;
	public String address1;
	public String homePhone;
	public String mobilePhone;
	public String workPhone;
	public String email;
	public String email2;
	public String bday;
	public String bmonth;
	public String byear;
	public String group;
	public String address2;
	public String phone2;
	
	public PersonData(){	
	}
	
	public PersonData(String secondName, String firstName, String address1,
			String homePhone, String mobilePhone, String workPhone,
			String email, String email2, String bday, String bmonth,
			String byear, String group, String address2, String phone2) {	
		this.secondName = secondName;
		this.firstName = firstName;
		this.address1 = address1;
		this.homePhone = homePhone;
		this.mobilePhone = mobilePhone;
		this.workPhone = workPhone;
		this.email = email;
		this.email2 = email2;
		this.bday = bday;
		this.bmonth = bmonth;
		this.byear = byear;
		this.group = group;
		this.address2 = address2;
		this.phone2 = phone2;
	}
	
	@Override
	public String toString() {
		return "PersonData [firstName=" + firstName + ", secondName="
				+ secondName + ", homePhone=" + homePhone + ", email=" + email
				+ "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((email == null) ? 0 : email.hashCode());
		result = prime * result
				+ ((firstName == null) ? 0 : firstName.hashCode());
		result = prime * result
				+ ((homePhone == null) ? 0 : homePhone.hashCode());
		result = prime * result
				+ ((secondName == null) ? 0 : secondName.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		PersonData other = (PersonData) obj;
		if (email == null) {
			if (other.email != null)
				return false;
		} else if (!email.equals(other.email))
			return false;
		if (firstName == null) {
			if (other.firstName != null)
				return false;
		} else if (!firstName.equals(other.firstName))
			return false;
		if (homePhone == null) {
			if (other.homePhone != null)
				return false;
		} else if (!homePhone.equals(other.homePhone))
			return false;
		if (secondName == null) {
			if (other.secondName != null)
				return false;
		} else if (!secondName.equals(other.secondName))
			return false;
		return true;
	}
	
	@Override
	public int compareTo(PersonData other) {
		return (this.secondName.toLowerCase()+" "+this.firstName.toLowerCase()+" "+this.email.toLowerCase()+" "+this.homePhone.toLowerCase())
				.compareTo(other.secondName.toLowerCase()+" "+other.firstName.toLowerCase()+" "+other.email.toLowerCase()+" "+other.homePhone.toLowerCase());		
	}


}